package com.yxc.plan.wolf.controller;

import com.yxc.plan.wolf.common.ServerResponse;
import com.yxc.plan.wolf.domain.Product;
import com.yxc.plan.wolf.service.interfaces.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.PageableDefault;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
* @Description : 
* @Author      : abc@.com
* @Date        : 2019-01-15 13:35
*/

@RestController
@RequestMapping(value = "/api/v1/home")
public class HomeProductController {

    @Autowired
    private ProductService productService;

    @GetMapping("/list")
    public ServerResponse<List<Product>> list(@PageableDefault(page = 0, size = 10, sort = {"id"}, direction = Sort.Direction.DESC) Pageable pageable) {
        return productService.list(pageable);
    }
}
